from threading import Thread
import sys
import random

class MyThread(Thread):
    def __init__(self, iter_number):
        Thread.__init__(self)
        self.iter_number = iter_number
        self.in_num = 0
        self.all_num = 0

    def run(self):
        for i in range(0, self.iter_number):
            ran_num1 = random.uniform(0.0,100.0)
            ran_num2 = random.uniform(0.0,100.0)
            if (pow(ran_num1, 2) + pow(ran_num2, 2)) < 10000:
                self.in_num = self.in_num + 1
            self.all_num = self.all_num + 1

    def get_result(self):
        return (self.in_num, self.all_num)


all_item_time = int(sys.argv[1])
thread_num = int(sys.argv[2])

# thd = []

# for i in range(0, thread_num):
#     thd.append(MyThread(int(all_item_time/thread_num)))


# for i in range(0, thread_num):
#     thd[i].start()

# for i in range(0, thread_num):
#     thd[i].join()
item_time = int(all_item_time / thread_num)

result = {}

result["in"] = 0
result["all"] = 0

for i in range(0, item_time):
    ran_num1 = random.uniform(0.0,100.0)
    ran_num2 = random.uniform(0.0,100.0)
    if (pow(ran_num1, 2) + pow(ran_num2, 2)) < 10000:
        result["in"] = result["in"] + 1
    result["all"] = result["all"] + 1


result["in"] = result["in"] * thread_num
result["all"] = result["all"] * thread_num

# for i in range(0, thread_num):
#     in_count, all_count = thd[i].get_result()
#     result["in"] = result["in"] + in_count
#     result["all"] = result["all"] + all_count


for key, value in result.items():
	sys.stdout.write("%s\t%s\n" % (key, str(value)))


